<template>
  <div style="position: relative">
    <!-- <div class="flex_right">
      <right-toolbar @queryTable="updateFlag" :columns="columns">
      </right-toolbar>
    </div> -->
    <el-table v-loading="loading" :data="noticeList">
      <el-table-column label="序号" align="center" prop="order" width="50" />
      <!-- <el-table-column label="图片" align="center" min-width="120">
        <template slot-scope="scope">
          <el-image fit="cover" style="width:100px;height:100px" :src="scope.row.image"></el-image>
        </template>
      </el-table-column> -->
      <el-table-column label="区域编号" align="center" min-width="180">
        <template slot-scope="scope">
          {{ scope.row.areaNum || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="区域名称" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.areaName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="设备编号" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.equipmentNum || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="设备名称" align="center" width="160">
        <template slot-scope="scope">
          <span>{{ scope.row.equipmentName || '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="品牌" align="center" width="160">
        <template slot-scope="scope">
          <span>{{ scope.row.brand || '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="巡检员" align="center" min-width="120">
        <template slot-scope="scope">
          {{
              scope.row.inspectionBy || '-'
          }}

        </template>
      </el-table-column>
      <el-table-column label="巡检时间" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.inspectionTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" width="160" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.remark || '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" width="160">
        <template slot-scope="scope">
          <dict-tag :options="inspectionStatusTwo" :value="scope.row.areaInspectionStatus" />
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="180" fixed="right" align="center">
        <template slot-scope="scope">
          <el-button v-hasPermi="['manage_basevalue_img']" size="small" type="primary" icon="el-icon-view"
            @click="handleSelectImage(scope.row.images)">图片
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="card-div">
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>
    <template v-if="ImageOpen">
      <DialogImage :src="ImageSrc"></DialogImage>
      <!-- <el-image-viewer :on-close="() => { ImageOpen = false }" :url-list="[ImageSrc]" /> -->
    </template>
  </div>
</template>

<script>
import { getSelectequipmentsList } from "@/api/equipmentInspct/index.js";

export default {
  // dicts: ['sys_notice_status', 'sys_notice_type'],
  props: ['rowObj'],
  components: {
  },
  data () {
    return {
      // 遮罩层
      loading: true,
      opendetailed: false,
      detailedObj: {},
      specifyTime: null,
      ImageOpen: false,
      ImageSrc: '',
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      dictdatalist: [],
      // 显示搜索条件
      showSearch: true,
      condition: '',
      // 总条数
      total: 0,
      // 弹出层表格数据
      noticeList: [],
      // 弹出层标题
      title: "",
      DisObj: {},
      DisShow: false,
      // 是否显示弹出层
      open: false,
      // 列信息
      columns: [
        { key: 0, label: `设备名称`, visible: true, disabled: true },
        { key: 1, label: `品牌`, visible: true },
        { key: 2, label: `规格型号`, visible: true },
        { key: 3, label: `单位`, visible: true },
        { key: 4, label: `供应商`, visible: true, disabled: true },
        { key: 5, label: `计量设备`, visible: true, disabled: true },
        { key: 6, label: `计量编号`, visible: true },
        { key: 7, label: `类别`, visible: true, disabled: true },
        { key: 8, label: `状态`, visible: true, disabled: true },
        { key: 9, label: `附件`, visible: true, disabled: true },
        { key: 10, label: `备注`, visible: true },
        { key: 11, label: `创建部门`, visible: true },
        { key: 12, label: `创建人`, visible: true }
      ],
      openSelect: false,
      selection: null,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        // orderByColumn: 'id',
        isAsc: 'desc'//倒叙
      },
      // 表单参数
      form: {},
    };
  },
  created () {
    if (!this.$route.query.isCondition) {
      this.getList();
    }
    // this.getcolumns();
  },
  watch: {
    columns: {//监听动态列修改调用更新方法
      handler (val) {
        this.updateFlag()
      },
      deep: true
    }
  },
  methods: {
    handleSelectImage (src) {
      this.ImageOpen = true
      this.ImageSrc = src && src.split(';')
    },
    /** 查询列表 */
    async getList (value) {
      this.loading = true;
      let params = {
        ...this.queryParams,
        ...value,
        id: this.rowObj.id
      }
      //  let data = await getdatalist({ dictType: 'base_unit' })
      //  this.dictdatalist=data.data
      getSelectequipmentsList(params).then(response => {
        this.noticeList = response.data && response.data.map((item, index) => {
          return {
            ...item,
            order: index + 1
          }
        });
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel () {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset () {
      this.form = {
        noticeId: undefined,
        noticeTitle: undefined,
        noticeType: undefined,
        noticeContent: undefined,
        status: "0"
      };
      this.resetForm("form");
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange (selection) {
      this.ids = selection.map(item => item.noticeId)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    /** 启用禁用按钮操作 */
    handleDelete (row) {
      if (row.planStatus === '1') {//为启用
        this.DisShow = true
        this.DisObj = row
        return false
      }
      const noticeIds = row.title || '无名称'
      this.$confirm(`是否确认${row.planStatus === '0' ? `禁用` : `启用`}标题为${noticeIds}的数据？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.loading = true;
        let params = {
          id: row.id,
          planStatus: row.planStatus === '0' ? 1 : 0
        }
        putUpdateplanstatus(params).then(res => {
          if (res.code === 200) {
            this.loading = false;
            this.$message.success(res.msg)
            this.getList()
          }
        })
      }).catch(() => { this.loading = false; });
    }
  },
  filters: {
  }

};
</script>
<style lang="scss" scoped>
.red {
  color: red;
}

.flex_right {
  position: absolute;
  top: -50px;
  right: 0px
}
</style>